<?php
class citydao extends CI_Model{
	function __construct()
	{
		// Call the Model constructor
		parent::__construct();
	}

	public function insert($city_name,$city_code){
		$data = array(
				'city_name' => $city_name,
				'city_code' => $city_code
		);
		$str = $this->db->insert_string('city', $data);
		$res = $this->db->query($str);
		if (!$res) {
			return false;
		} else {
			return true;
		}
	}

	public function del($city_name) {
			$this->db->where('city_name', $city_name);
			$this->db->delete('city');
			return ($this->db->affected_rows() == 1) ? TRUE : FALSE;
	}

	public function getbyid($city_name){
		$this->db->select('*');
		$this->db->from('city');
		$this->db->where('city_name',$city_name);
		$query = $this->db->get();
		$city = $query->row();
		return $city;
	}

	public function get_all(){
		$this->db->select('*');
		$this->db->from('city');
		$query = $this->db->get();
		$cities = $query->result();
		return $cities;
	}

}
